import json
from werkzeug.exceptions import HTTPException

## 客户端异常处理方法
def handle_exception(e):
    print(e)
    response = e.get_response()
    response.data = json.dumps({
        "code": e.code,
        "name": e.name,
        "description": e.description,
    })
    response.content_type = "application/json"
    return response 

# 服务端异常处理方法
# def handle_500_exception(e):
#     if isinstance(e, HTTPException):
#         return e

#     return render_template("500_generic.html", e=e), 500
